package ui.action;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JOptionPane;
import ui.UIMainWin;

@SuppressWarnings("serial")
public class ActionDeleteLecture extends AbstractAction{
	
	UIMainWin win;
	
	
	public ActionDeleteLecture(String name, UIMainWin win){
		super(name);
		this.win = win;
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		
		int selectedRow = win.getLectureTable().getSelectedRow();
		if(selectedRow != -1){

			win.getSm().deleteLecture(selectedRow);
			win.refreshLectureTable();
			JOptionPane.showMessageDialog(win,
				    "Correctly deleted", 
				    "Message",JOptionPane.INFORMATION_MESSAGE);
			
		}
		else{
			JOptionPane.showMessageDialog(win,
				    "No selected row",
				    "Error",
				    JOptionPane.ERROR_MESSAGE);
		}
		
	}

}
